//
//  NSChatNullView.m
//  Meboo
//
//  Created by kyo on 2024/5/10.
//

#import "NSChatNullView.h"
@interface NSChatNullView ()
@property (nonatomic, strong) UIImageView *noDataImageView;
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UIButton *continueBtn;
@end

@implementation NSChatNullView

#pragma mark - Life Cycle
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

#pragma mark - Action

- (void)nextAction {
    
    [self.currentViewController.navigationController popViewControllerAnimated:YES];
//    self.currentViewController.tabBarController.selectedIndex = 0;
}

#pragma mark - UI
- (void)setupUI {
    self.hidden = YES;
    self.backgroundColor = UIColor.clearColor;
    
    [self addSubview:self.titleLab];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(MBWidthScale(44));
        make.right.mas_equalTo(MBWidthScale(-44));
        make.centerY.mas_offset(MBHeightScale(23));
    }];
    
    [self addSubview:self.noDataImageView];
    [self.noDataImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.bottom.equalTo(self.titleLab.mas_top).offset(MBHeightScale(-30));
        make.width.mas_equalTo(MBWidthScale(129));
        make.height.mas_equalTo(MBWidthScale(129)/129*110);
    }];
    
    [self addSubview:self.continueBtn];
    [self.continueBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.width.mas_equalTo(MBWidthScale(200));
        make.height.mas_equalTo(MBHeightScale(52));
        make.top.equalTo(self.titleLab.mas_bottom).offset(MBHeightScale(20));
    }];
}

#pragma mark - Setter && Getter

- (UILabel *)titleLab {
    if (!_titleLab) {
        _titleLab = [UILabel new];
        _titleLab.numberOfLines = 0;
        _titleLab.textAlignment = NSTextAlignmentCenter;
        _titleLab.text = @"We are working hard to find you the special ones! Please be patient, save the best for the last";
        _titleLab.font = MBHelFontSizeScale(16);
        _titleLab.textColor = HEXS(@"000000");
    }
    return _titleLab;
}

- (UIButton *)continueBtn {
    if (!_continueBtn) {
        _continueBtn = [UIButton new];
        [_continueBtn setBackgroundColor:HEXS(@"B92176")];
        _continueBtn.layer.cornerRadius = MBHeightScale(52/2);
        [_continueBtn setTitle:@"See your admirers" forState:0];
        [_continueBtn setTitleColor:HEXS(@"ffffff") forState:0];
        _continueBtn.titleLabel.font = MBHelFontSizeScale(16);
        [_continueBtn addTarget:self action:@selector(nextAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _continueBtn;
}

- (UIImageView *)noDataImageView {
    if (!_noDataImageView) {
        _noDataImageView = [UIImageView new];
        _noDataImageView.contentMode = UIViewContentModeScaleAspectFill;
        _noDataImageView.image = ImageWithName(@"chat_list_nodata_icon");
    }
    return _noDataImageView;
}
@end
